package demo13;

import java.util.Random;

/**
 * Created by Administrator on 2017/6/19.
 */
public class MathRandomChar {
    public static char GetRandomChar(char cha1, char cha2) {
        return (char) (cha1 + Math.random() * (cha2 - cha1 + 1));
    }

    public static void main(String[] args) {
        System.out.println("任意小写字符" + GetRandomChar('a', 'z'));
        System.out.println("任意大写字符" + GetRandomChar('A', 'Z'));
        System.out.println("0~9任意数字字符" + GetRandomChar('0', '9'));
        Random r = new Random();
        System.out.println("随机产生一个整数：" + r.nextInt());
        System.out.println("随机产生一个大于等于0小于10整数：" + r.nextInt(10));
        System.out.println("随机产生一个布尔型的值：" + r.nextBoolean());
        System.out.println("随机产生一个双精度型的值：" + r.nextDouble());
        System.out.println("随机产生一个浮点型的值：" + r.nextFloat());
        System.out.println("随机产生一个概率密度为高斯分布的双精度值：" + r.nextGaussian());
    }
}
